package com.example.mountainwalker.controller;

import com.example.mountainwalker.entity.GroupTourInfo;
import com.example.mountainwalker.service.GroupTourService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/mw")
@CrossOrigin
public class GroupTourController {

    @Autowired
    private GroupTourService groupTourService;

    // http://localhost:8080/mw/GroupTourList
    @GetMapping("/GroupTourList")
    public List<GroupTourInfo> getGroupTourList() {
        return groupTourService.getGroupTourList();
    }

    // http://localhost:8080/mw/GroupTourById?id=1
    @GetMapping("/GroupTourById")
    public GroupTourInfo getGroupTourById(@RequestParam Integer id) {
        return groupTourService.getGroupTourById(id);
    }

    // http://localhost:8080/mw/deleteGroupTourById?id=1
    @DeleteMapping("/deleteGroupTourById")
    public int deleteGroupTourById(@RequestParam Integer id) {
        return groupTourService.deleteGroupTourById(id);
    }
    // http://localhost:8080/mw/addGroupTour
    @PostMapping("/addGroupTour")
    public int addGroupTour(@RequestBody GroupTourInfo groupTourInfo) {
        return groupTourService.addGroupTour(groupTourInfo);
    }

    // http://localhost:8080/mw/updateGroupTour
    @PutMapping("/updateGroupTour")
    public int updateGroupTour(@RequestBody GroupTourInfo groupTourInfo) {
        return groupTourService.updateGroupTour(groupTourInfo);
    }

}
